// 头部变量
var HomePage=document.querySelector('.Home-page');
var Plate=document.querySelector('.Plate');
var SearchBoxImg=document.querySelector('.search-box img');
var SearchBoxInp=document.querySelector('.search-box input');
var News=document.querySelector('#news');
var MessagePage=document.querySelector('.Message-page');
var CloseMessagePage=document.querySelector('.Message-page>div>div>img');
//目录变量
var CatalogueLi=document.querySelectorAll('.Catalogue li');
//内容变量
var Route=document.querySelector('.route');
var PathEnd=document.querySelector('.Path-end');
var keywordImg=document.querySelector('.keyword img');
var keywordInp=document.querySelector('.keyword input');
var SearchBoxSpan=document.querySelector('.Search-box>span');
var SearchBoxLi=document.querySelectorAll('.Search-box>ul>li');
var Check=document.querySelector('#check');
var Checkbox;
var CheckNumber=0;
var isChecked=false;
var isCheckboxed=[];
//渲染页面变量
var data=[
    {index:'1',RequisitionNo:'LY20220303001',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'张三',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'张三',},
    {index:'2',RequisitionNo:'LY20220303002',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'张三',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'张三',},
    {index:'3',RequisitionNo:'LY20220303003',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'张三',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'张三',},
    {index:'4',RequisitionNo:'LY20220303004',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'张三',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'张三',},
    {index:'5',RequisitionNo:'LY20220303005',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'张三',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'6',RequisitionNo:'LY20220303006',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'7',RequisitionNo:'LY20220303007',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'7000.00',HandledBy:'弥冬灵',},
    {index:'8',RequisitionNo:'LY20220303008',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'李四',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'李四',},
    {index:'9',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'李四',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'6000.00',HandledBy:'李四',},
    {index:'10',RequisitionNo:'LY20220303010',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'李四',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'李四',},
    {index:'11',RequisitionNo:'LY20220303011',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'李四',CollectionDate:'2022-03-15',TotalQuantity:'3',TotalAmount:'8000.00',HandledBy:'李四',},
    {index:'12',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'研发部',Receiver:'李四',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'李四',},
    {index:'13',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'研发部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'14',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'研发部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'4000.00',HandledBy:'弥冬灵',},
    {index:'15',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'研发部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'4',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'16',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'研发部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'17',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'研发部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'5000.00',HandledBy:'弥冬灵',},
    {index:'18',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'研发部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'19',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'研发部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'20',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'研发部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'5',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'22',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'研发部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'23',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'24',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'3',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'25',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'26',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'27',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'营销部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'6',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'28',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'营销部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'29',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'营销部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'30',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'营销部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'31',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'营销部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'32',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'营销部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'33',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'营销部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'34',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'35',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'36',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'37',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'38',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'39',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
    {index:'40',RequisitionNo:'LY20220303009',AssetDetails:'联想thinkplus会议平板；明基显示屏',ReceivingDepartment:'产品部',Receiver:'弥冬灵',CollectionDate:'2022-03-15',TotalQuantity:'2',TotalAmount:'8000.00',HandledBy:'弥冬灵',},
];
var page=1;
var count=10;
var Tbody=document.querySelector('tbody');
var Pagination=document.querySelector('.pagination');
var FirstBtn=document.querySelector('.first');
var PrevBtn=document.querySelector('.prev');
var NextBtn=document.querySelector('.next');
var LastBtn=document.querySelector('.last');
var TotalNumber=document.querySelector('.Total-number');
//添加变量
var ContractContentPage=document.querySelector('.Contract-content-page')
var AddContractPage=document.querySelector('.Add-contract-page')
var Add=document.querySelector('.add');
var AddPreservation=document.querySelector('.Add-contract-page .preservation')
var AddCancel=document.querySelector('.Add-contract-page .cancel')
//编辑变量
var EditContractPage=document.querySelector('.edit-contract-page');
var EditPreservation=document.querySelector('.edit-contract-page .preservation')
var EditCancel=document.querySelector('.edit-contract-page .cancel');

//头部
HomePage.onclick=function(){
    if(HomePage.className!='.active'){
        Plate.classList.remove('active');
        HomePage.classList.add('active');
        $('.plate-type').slideUp('fast');
    }
}
Plate.onclick=function(){
    if(Plate.className!='.active'){
        HomePage.classList.remove('active');
        Plate.classList.add('active')
    }
}
$('.Plate').click(function(){
    $('.plate-type').slideToggle('fast');
})
SearchBoxImg.onmouseenter=function(){
    SearchBoxImg.src='../../images/yqy_images/header/heder_search.png';
}
SearchBoxImg.onmouseleave=function(){
    SearchBoxImg.src='../../images/yqy_images/header/heder_search_mouseOver.png';
}
$('.Header-right div').click(function(){
    $('.personal-information5').slideToggle('fast');
})
News.onclick=function(){
    MessagePage.style.display='block';
}
CloseMessagePage.onclick=function(){
    MessagePage.style.display='none';
}

//目录
for(var i=0;i<CatalogueLi.length;i++){
    CatalogueLi[i].onmouseenter=function(){
        if(this.className==''){
            this.style.background='rgba(26, 107, 232, 0.0470588235294118)';
            this.onclick=function(){
                for(var i=0;i<CatalogueLi.length;i++){
                    this.style.background=''
                    CatalogueLi[i].className='';
                    this.className='active';
                    PathEnd.innerHTML=this.firstElementChild.innerHTML;

                }
            }
        }
    }
    CatalogueLi[i].onmouseleave=function(){
        if(this.className==''){
            this.style.background='';
        }
    }
}
$('.Catalogue div').click(function(){
    $(this).next().slideToggle('fast');
    if($(this).find('p').find('img').get(0).style.transform=='rotate(90deg)'){
        console.log(1);
        $(this).find('p').find('img').css('transform','rotate(180deg)');
    }else{
        console.log(2);
        $(this).find('p').find('img').css('transform','rotate(90deg)');
    }
});

//内容
keywordImg.onmouseenter=function(){
    this.src='../../images/yqy_images/header/heder_search.png';
}
keywordImg.onmouseleave=function(){
    this.src='../../images/yqy_images/content/content_search2.png';
}
$('.Search-box').click(function(){
    $(this).children('ul').slideToggle();
    event.cancelBubble=true;
});
$('.Search-box>ul>li').click(function(){
    $(this).parent().prev().prev().text(this.innerHTML);
})
$('#Box').click(function(){
    $('.Search-box').children('ul').slideUp();
});
function render(){
    var str=SearchBoxSpan.innerHTML;
    var str2=keywordInp.value;
    var SearchData=[];
    var SearchData2=[];
    if(str=='请选择'){
        SearchData=data;
    }else{
        for(var i=0;i<data.length;i++){
            if(data[i].ReceivingDepartment==str){
                SearchData.push(data[i]);
            }
        }
    }
    if(str2==''){
        SearchData2=SearchData;
    }else{
        for(var i=0;i<SearchData.length;i++){
            for(var key in SearchData[i]){
                if(SearchData[i][key].includes(str2)){
                    SearchData2.push(SearchData[i]);
                    break;
                }
            }
        }
    }
    if(page>Math.ceil(SearchData2.length/count)){
        page=Math.ceil(SearchData2.length/count);
    }
    if(page<1){
        page=1;
    }
    Tbody.innerHTML='';
    var RenderArr=SearchData2.slice((page-1)*count,page*count);
    //总条数
    TotalNumber.innerHTML='共'+SearchData2.length+'条';
//渲染内容
    for(var i=0;i<RenderArr.length;i++){
        var Tr=document.createElement('tr');
        Tr.innerHTML=`
        <td><img class="checkbox" src="../../images/yqy_images/content/content_check.png"></td>
        <td><span style="color:blue;">${RenderArr[i].RequisitionNo}</span></td>
        <td><span>${RenderArr[i].AssetDetails}</span></td>
        <td><span>${RenderArr[i].ReceivingDepartment}</span></td>
        <td><span>${RenderArr[i].Receiver}</span></td>
        <td><span>${RenderArr[i].CollectionDate}</span></td>
        <td><span>${RenderArr[i].TotalQuantity}</span></td>
        <td><span>${RenderArr[i].TotalAmount}</span></td>
        <td><span>${RenderArr[i].HandledBy}</span></td>
        <td><a class="edit">编辑</a><a class="del">删除</a></td>
        `;
        Tr.index=RenderArr[i].index;
        Tbody.appendChild(Tr);
    }
    Checkbox=document.querySelectorAll('.checkbox');
//渲染分页
    var PageBtn=document.querySelectorAll('.pageBtn');
    for(var i=0;i<PageBtn.length;i++){
        Pagination.removeChild(PageBtn[i].parentNode);
    }
    for(var i=1;i<=Math.ceil(SearchData2.length/count);i++){
        var Li=document.createElement('li');
        Li.innerHTML=`<a class="pageBtn" href="#">${i}</a>`;
        if(i==page){
            Li.classList.add('active');
        };
        Pagination.insertBefore(Li,Pagination.children[Pagination.children.length-2]);
    }
}
render();

//选项
Check.addEventListener('mouseenter',checkEnterFn);
Check.addEventListener('mouseleave',checkLeaveFn);
for(var i=0;i<Checkbox.length;i++){
    Checkbox[i].addEventListener('mouseenter',checkboxEnterFn);
    Checkbox[i].addEventListener('mouseleave',checkboxLeaveFn);
    isCheckboxed.push(false);
    Checkbox[i].index=i;
}
function checkEnterFn(){
    if(isChecked==false){
        this.src='../../images/yqy_images/content/content_check_mouseOver.png';
    }
}
function checkboxEnterFn(){
    if(isCheckboxed[this.index]==false){
        this.src='../../images/yqy_images/content/content_check_mouseOver.png';
    }
}
function checkLeaveFn(){
    if(isChecked==false){
        this.src='../../images/yqy_images/content/content_check.png';
    }
}
function checkboxLeaveFn(){
    if(isCheckboxed[this.index]==false){
        this.src='../../images/yqy_images/content/content_check.png';
    }
}
Check.onclick=function(){
    isChecked=!isChecked;
    if(isChecked){
        Check.src='../../images/yqy_images/content/content_checked.png';
        for(var i=0;i<Checkbox.length;i++){
            isCheckboxed[i]=!isCheckboxed[i];
            Checkbox[i].src='../../images/yqy_images/content/content_checked.png';
            CheckNumber=Checkbox.length;
        }
    }else{
        Check.src='../../images/yqy_images/content/content_check_mouseOver.png';
        for(var i=0;i<Checkbox.length;i++){
            isCheckboxed[i]=!isCheckboxed[i];
            Checkbox[i].src='../../images/yqy_images/content/content_check.png';
            CheckNumber=0;
        }
    }
}
for(var i=0;i<Checkbox.length;i++){
    Checkbox[i].index=i;
    Checkbox[i].onclick=function(){
        isCheckboxed[this.index]=!isCheckboxed[this.index]
        if(isCheckboxed[this.index]){
            this.src='../../images/yqy_images/content/content_checked.png';
            CheckNumber++;
        }else{
            this.src='../../images/yqy_images/content/content_check_mouseOver.png';
            CheckNumber--;
        }
        if(CheckNumber==Checkbox.length){
            isChecked=true;
            Check.src='../../images/yqy_images/content/content_checked.png';
        }else{
            isChecked=false;
            Check.src='../../images/yqy_images/content/content_check.png';
        }
    }
}

Pagination.addEventListener('click',changePage);
function changePage(){
    if(event.target.className=='pageBtn'){
        page=event.target.innerText;
        render();
    }
}
PrevBtn.addEventListener('click',prevFn);
FirstBtn.addEventListener('click',firstFn);
NextBtn.addEventListener('click',nextFn);
LastBtn.addEventListener('click',lastFn);
function prevFn(){
    if(page>1){
        page--;
        render();
    }
}
function firstFn(){
    if(page!=1){
        page=1;
        render();
    }
}
function nextFn(){
    if(page<Pagination.children.length-4){
        page++;
        render();
    }
}
function lastFn(){
    if(page!=Pagination.children.length-4){
        page=Pagination.children.length-4;
        render();
    }
}
Tbody.addEventListener('click',delFn);
function delFn(){
    if(event.target.className.includes('del')){
        var index=event.target.parentNode.parentNode.index;
        for(var i=0;i<data.length;i++){
            if(data[i].index==index){
                data.splice(i,1);
            }
        }
        render();
        return;
    }
}
//搜索
for(var i=0;i<SearchBoxLi.length;i++){
    SearchBoxLi[i].addEventListener('click',Search1Fn);
}
function Search1Fn(){
    page=1;
    render();
}
keywordImg.addEventListener('click',Search2Fn);
function Search2Fn(){
    page=1;
    render();
}

//添加
Add.onclick=function(){
    ContractContentPage.style.display='none';
    AddContractPage.style.display='block';
    Route.innerHTML='资产 &gt 库存管理 &gt 领用 &gt';
    PathEnd.innerHTML='新增领用申请';
}
AddCancel.onclick=function(){
    var AddIndex=document.getElementById('addIndex').value.trim();
    var AddRequisitionNo=document.getElementById('addRequisitionNo').value.trim();
    var AddAssetDetails=document.getElementById('addAssetDetails').value.trim();
    var AddReceivingDepartment=document.getElementById('addReceivingDepartment').value.trim();
    var AddReceiver=document.getElementById('addReceiver').value.trim();
    var AddCollectionDate=document.getElementById('addCollectionDate').value.trim();
    var AddTotalQuantity=document.getElementById('addTotalQuantity').value.trim();
    var AddTotalAmount=document.getElementById('addTotalAmount').value.trim();
    var AddHandledBy=document.getElementById('addHandledBy').value.trim();
    ContractContentPage.style.display='block';
    AddContractPage.style.display='none';
    AddIndex='';
    AddRequisitionNo='';
    AddAssetDetails='';
    AddReceivingDepartment='';
    AddReceiver='';
    AddCollectionDate='';
    AddTotalQuantity='';
    AddTotalAmount='';
    AddHandledBy='';
    Route.innerHTML='资产 &gt 库存管理 &gt';
    PathEnd.innerHTML='领用';
}
AddPreservation.addEventListener('click',AddPreservationFn)
function AddPreservationFn(){
    var AddIndex=document.getElementById('addIndex').value.trim();
    var AddRequisitionNo=document.getElementById('addRequisitionNo').value.trim();
    var AddAssetDetails=document.getElementById('addAssetDetails').value.trim();
    var AddReceivingDepartment=document.getElementById('addReceivingDepartment').value.trim();
    var AddReceiver=document.getElementById('addReceiver').value.trim();
    var AddCollectionDate=document.getElementById('addCollectionDate').value.trim();
    var AddTotalQuantity=document.getElementById('addTotalQuantity').value.trim();
    var AddTotalAmount=document.getElementById('addTotalAmount').value.trim();
    var AddHandledBy=document.getElementById('addHandledBy').value.trim();
    function repeat(){
        for(var i=0;i<data.length;i++){
            if(AddIndex==data[i].index){
                return true;
            }
        }
        return false;
    }
    if(repeat()==false){
        data.push({
            Index:AddIndex,
            RequisitionNo:AddRequisitionNo,
            AssetDetails:AddAssetDetails,
            ReceivingDepartment:AddReceivingDepartment,
            Receiver:AddReceiver,
            CollectionDate:AddCollectionDate,
            TotalQuantity:AddTotalQuantity,
            TotalAmount:AddTotalAmount,
            HandledBy:AddHandledBy,
        })
        render();
        ContractContentPage.style.display='block';
        AddContractPage.style.display='none';
        AddIndex='';
        AddRequisitionNo='';
        AddAssetDetails='';
        AddReceivingDepartment='';
        AddReceiver='';
        AddCollectionDate='';
        AddTotalQuantity='';
        AddTotalAmount='';
        AddHandledBy='';
        Route.innerHTML='资产 &gt 库存管理 &gt';
        PathEnd.innerHTML='领用';
    }else{
        alert('index不能重复')
    }
}

//编辑
EditCancel.onclick=function(){
    ContractContentPage.style.display='block';
    EditContractPage.style.display='none';
}
Tbody.addEventListener('click',openEditFn);
function openEditFn(){
    if(event.target.className.includes('edit')){
        ContractContentPage.style.display='none';
        EditContractPage.style.display='block';
        var index=event.target.parentNode.parentNode.index;
        for(var i=0;i<data.length;i++){
            if(data[i].index==index){
                document.getElementById('editIndex').value=data[i].index;
                document.getElementById('editRequisitionNo').value=data[i].RequisitionNo;
                document.getElementById('editAssetDetails').value=data[i].AssetDetails;
                document.getElementById('editReceivingDepartment').value=data[i].ReceivingDepartment;
                document.getElementById('editReceiver').value=data[i].Receiver;
                document.getElementById('editCollectionDate').value=data[i].CollectionDate;
                document.getElementById('editTotalQuantity').value=data[i].TotalQuantity;
                document.getElementById('editTotalAmount').value=data[i].TotalAmount;
                document.getElementById('editHandledBy').value=data[i].HandledBy;
            }
        }
    }
}
EditPreservation.addEventListener('click',editFn);
function editFn(){
    var index=document.getElementById('editIndex').value;
    for(var i=0;i<data.length;i++){
        if(data[i].index==index){
                data[i].AssetDetails=document.getElementById('editAssetDetails').value;
                data[i].ReceivingDepartment=document.getElementById('editReceivingDepartment').value;
                data[i].Receiver=document.getElementById('editReceiver').value;
                data[i].CollectionDate=document.getElementById('editCollectionDate').value;
                data[i].TotalQuantity=document.getElementById('editTotalQuantity').value;
                data[i].TotalAmount=document.getElementById('editTotalAmount').value;
                data[i].HandledBy=document.getElementById('editHandledBy').value;
        }
    }
    render();
    ContractContentPage.style.display='block';
    EditContractPage.style.display='none';
}